package edu.kit.aifb.ruleintegrator.rule;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;

import org.apache.commons.collections.map.LinkedMap;
import org.apache.commons.collections.map.MultiValueMap;
import org.semanticweb.yars.nx.Variable;

import edu.kit.aifb.ruleintegrator.util.RuleException;

public class Signature {
	private static int id=0;
	private List<Variable> m_variables;
	
	// a predicate can be used with different mappings. So it is multi value map.	
//	private MultiValueMap m_map= MultiValueMap.decorate(new LinkedMap());
	
	public Signature(Variable[] vars){		
		this.m_variables=new ArrayList<Variable>(Arrays.asList(vars));
		
	}
	
//	public void addMapping(SignatureMapping sm) throws RuleException{
//		for(Variable var:sm.getVariables()){
//			if(!this.m_variables.contains(var)){
//				throw new RuleException("Cannot map the variable for predicate "+sm.getPredicate()+" since variable "+var+" does not exist."); 
//			}
//		}
//		m_map.put(sm.getPredicate(), sm);
//	}
//	
//	public Collection getMappings(Predicate pred){
//		return m_map.getCollection(pred);
//	}
//	
//	public void removeMapping(Predicate pred, SignatureMapping sm){
//		m_map.remove(pred, sm);
//	}
	
	
	public void addVariable(Variable var) throws RuleException{
		if(m_variables.contains(var))
			throw new RuleException("Variable "+var+" is already defined");
		m_variables.add(var);
	}
	
	public static Variable createNewVariable(){
		return new Variable("var"+id++);		
	}
	

}
